/**
 * ...
 * @author Krzysztof Rozalski
 */

package hapi.util.benchmark.test;
import hapi.util.benchmark.BenchmarkRunner;
import hapi.util.benchmark.Const;
import hapi.util.benchmark.FunctionBenchmark;

class Literals 
{

	static inline var ITERATIONS_NUM = 10000000;
	
	public static function perform(runner:BenchmarkRunner) {
		var f1 = function() {
			for( i in 0...ITERATIONS_NUM ) {
				var a = i+(1000/23+24.5-17.8*16)+(1000/23+24.5-17.8*16)-(1000/23+24.5-17.8*16);
			}
		}
		var f2 = function() {
			for( i in 0...ITERATIONS_NUM ) {
				var a = i-216.821739;
			}
		}
		var f3 = function() {
			for( i in 0...ITERATIONS_NUM ) {
				var a = i+(Const.C1/Const.C2+Const.C3-Const.C4*Const.C5)+(Const.C1/Const.C2+Const.C3-Const.C4*Const.C5)-(Const.C1/Const.C2+Const.C3-Const.C4*Const.C5);
			}
		}
		var f4 = function() {
			var b = 216.821739;
			for( i in 0...ITERATIONS_NUM ) {
				var a = i -b;
			}
		}
		runner.add(new FunctionBenchmark("static-inline", f3, 1));
		runner.add(new FunctionBenchmark("inline", f2, 1));
		runner.add(new FunctionBenchmark("formula", f1, 1));
		runner.add(new FunctionBenchmark("variable", f4, 1));
	}
	
}